package com.edu.exam.entity.assessment.technical;

import com.edu.exam.enums.ConfigType;
import com.edu.exam.enums.ConfigStatus;
import com.edu.exam.enums.ComparisonScope;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;

import java.time.LocalDateTime;

/**
 * 试卷查重配置实体类
 * 所属模块：B-02 题库管理模块
 * 对应数据库表：question_check_config
 *
 * 根据B-03-10试卷查重子模块设计文档实现
 * 存储试卷查重的配置参数，支持多层级配置管理和灵活的参数调整。
 *
 * @author System
 * @version 1.0.0
 */

@Entity
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class QuestionCheckConfig {

    /**
     * 主键ID
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    /**
     * 配置名称
     */
    @Column(name = "config_name", nullable = false, length = 100)
    private String configName;

    /**
     * 配置类型
     */
    @Enumerated(EnumType.STRING)
    @Column(name = "config_type", nullable = false, length = 20)
    private ConfigType configType;

    /**
     * 配置适用目标ID
     */
    @Column(name = "target_id")
    private Long targetId;

    /**
     * 配置适用目标名称
     */
    @Column(name = "target_name", length = 100)
    private String targetName;

    /**
     * 默认相似度阈值
     */
    @Column(name = "similarity_threshold", precision = 4, scale = 3)
    private Double similarityThreshold;

    /**
     * 高度相似判断阈值
     */
    @Column(name = "highly_similar_threshold", precision = 4, scale = 3)
    private Double highlySimilarThreshold;

    /**
     * 中度相似判断阈值
     */
    @Column(name = "moderately_similar_threshold", precision = 4, scale = 3)
    private Double moderatelySimilarThreshold;

    /**
     * 低度相似判断阈值
     */
    @Column(name = "low_similarity_threshold", precision = 4, scale = 3)
    private Double lowSimilarityThreshold;

    /**
     * 默认查重范围
     */
    @Enumerated(EnumType.STRING)
    @Column(name = "default_comparison_scope", length = 20)
    private ComparisonScope defaultComparisonScope;

    /**
     * 分析维度配置（JSON格式存储）
     */
    @Column(name = "analysis_dimensions", columnDefinition = "TEXT")
    private String analysisDimensions;

    /**
     * 维度权重配置（JSON格式存储）
     */
    @Column(name = "dimension_weights", columnDefinition = "TEXT")
    private String dimensionWeights;

    /**
     * 算法配置参数（JSON格式存储）
     */
    @Column(name = "algorithm_config", columnDefinition = "TEXT")
    private String algorithmConfig;

    /**
     * 性能配置参数（JSON格式存储）
     */
    @Column(name = "performance_config", columnDefinition = "TEXT")
    private String performanceConfig;

    /**
     * 最大返回相似试卷数
     */
    @Column(name = "max_similar_papers")
    private Integer maxSimilarPapers;

    /**
     * 批量处理大小
     */
    @Column(name = "batch_size")
    private Integer batchSize;

    /**
     * 并行处理线程数
     */
    @Column(name = "parallelism")
    private Integer parallelism;

    /**
     * 任务超时时间（秒）
     */
    @Column(name = "timeout_seconds")
    private Integer timeoutSeconds;

    /**
     * 是否启用缓存
     */
    @Column(name = "cache_enabled", nullable = false)
    private Boolean cacheEnabled = true;

    /**
     * 缓存超时时间（秒）
     */
    @Column(name = "cache_timeout")
    private Integer cacheTimeout;

    /**
     * 是否启用通知
     */
    @Column(name = "notification_enabled", nullable = false)
    private Boolean notificationEnabled = false;

    /**
     * 通知配置参数（JSON格式存储）
     */
    @Column(name = "notification_config", columnDefinition = "TEXT")
    private String notificationConfig;

    /**
     * 配置启用状态
     */
    @Enumerated(EnumType.STRING)
    @Column(name = "status", nullable = false, length = 20)
    private ConfigStatus status;

    /**
     * 配置优先级
     */
    @Column(name = "priority")
    private Integer priority = 0;

    /**
     * 是否为默认配置
     */
    @Column(name = "is_default", nullable = false)
    private Boolean isDefault = false;

    /**
     * 创建者ID
     */
    @Column(name = "creator_id", length = 50)
    private Long creatorId;

    /**
     * 创建者姓名
     */
    @Column(name = "creator_name", length = 100)
    private String creatorName;

    /**
     * 创建时间
     */
    @CreationTimestamp
    @Column(name = "create_time", nullable = false, updatable = false)
    private LocalDateTime createTime;

    /**
     * 更新时间
     */
    @UpdateTimestamp
    @Column(name = "update_time")
    private LocalDateTime updateTime;

    /**
     * 版本号（用于乐观锁）
     */
    @Version
    @Column(name = "version", nullable = false)
    private Long version;

    /**
     * 是否删除
     */
    @Column(name = "is_deleted", nullable = false)
    private Boolean isDeleted = false;

}